package com.wk.code.wkserver.controller.admin;

import com.wk.code.wkserver.entity.EstimateAmount;
import com.wk.code.wkserver.entity.TechType;
import com.wk.code.wkserver.request.admin.EstimateAmountRequest;
import com.wk.code.wkserver.request.admin.TechTypeRequest;
import com.wk.code.wkserver.response.base.PageInfo;
import com.wk.code.wkserver.response.result.R;
import com.wk.code.wkserver.service.IEstimateAmountService;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wq
 * @since 2021-08-18
 */
@RestController
@RequestMapping("admin/estimate/amount")
@AllArgsConstructor
public class AdminEstimateAmountController {

    final IEstimateAmountService estimateAmountService;

    /**
     * 分页列表
     *
     * @param req 请求参数
     * @return R
     */
    @PostMapping("/page")
    public R<PageInfo<EstimateAmount>> page(@RequestBody EstimateAmountRequest req) {
        return R.success(estimateAmountService.page(req));
    }

    /**
     * 添加
     *
     * @param req 请求参数
     * @return R
     */
    @PostMapping("/add")
    public R<Void> add(@RequestBody EstimateAmountRequest req) {
        estimateAmountService.add(req);
        return R.success();
    }

    /**
     * 更新
     *
     * @param req req
     * @return R
     */
    @PostMapping("/update")
    public R<Void> update(@RequestBody EstimateAmountRequest req) {
        estimateAmountService.update(req);
        return R.success();
    }

    /**
     * 详情
     *
     * @param id ID
     * @return R
     */
    @GetMapping("/detail")
    private R<EstimateAmount> detail(Integer id) {
        return R.success(estimateAmountService.detail(id));
    }

    /**
     * 删除
     *
     * @param id ID
     * @return R
     */
    @GetMapping("/delete")
    private R<Void> delete(Integer id) {
        estimateAmountService.delete(id);
        return R.success();
    }

}
